package com.zdhr.igms.demain;

import java.io.Serializable;
import java.util.List;
/**
 * @Author: luolin
 * @Description: 公共分页Bean（Layui框架）
 * @Date: 2019-10-14 14:38
 * @Version: 1.0
 */
public class PageBean implements Serializable {
    // 当前页码
    private int page;
    // 每页显示数据的行数
    private int rows;
    // 数据获取的起始位置(数据库中)
    private int index;
    // 数据总条数
    private int totalRows;
    // 总共有多少页
    private int totalPage;
    // 排序字段
    private String sort;
    // 排序方式
    private String order;
    // 具体的数据
    private List<?> data;
    // Layui 框架table状态标识 code
    private Integer code;
    // Layui 框架table的msg标识 code
    private String msg;
    // Layui 框架table的总行数 count
    private Integer count;

    public PageBean() {
        super();
        // TODO Auto-generated constructor stub
    }

    public PageBean(int page, int rows) {
        super();
        this.page = page;
        this.rows = rows;
        //计算数据获取的起始位置
        this.index = (page - 1) * rows;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public int getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(int totalRows) {
        this.totalRows = totalRows;
        //总页码
        this.totalPage = totalRows % rows == 0 ? totalRows / rows : totalRows / rows + 1;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List<?> getData() {
        return data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public void setData(List<?> data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "page=" + page +
                ", rows=" + rows +
                ", index=" + index +
                ", totalRows=" + totalRows +
                ", totalPage=" + totalPage +
                ", sort='" + sort + '\'' +
                ", order='" + order + '\'' +
                ", data=" + data +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                ", count=" + count +
                '}';
    }
}
